package com.yy.base.util;

import java.security.MessageDigest;
import sun.misc.BASE64Encoder;

public class PasswordTool {
	/**
	 * 不可逆密码加密
	 */
	public static String md5Encode(String password) throws Exception {
		MessageDigest messageDigest = MessageDigest.getInstance("MD5");
		messageDigest.reset();
		messageDigest.update(password.getBytes());
		return new BASE64Encoder().encode(messageDigest.digest());
	}
	
	public static void main(String[] args) {
		try {
			System.out.println(PasswordTool.md5Encode("admin"));
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}